//
//  CommonFunction.h
//  mmbang
//
//  Created by yaodaobin on 2016/10/26.
//  Copyright © 2016年 iyaya. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>

@interface CommonFunction : NSObject

+ (NSString *)getValueFromDic:(NSDictionary *)dictionary withKey:(NSString *)key;

+ (NSMutableArray *)getArrayFromDic:(NSDictionary *)dictionary withKey:(NSString *)key;

//微信登录授权回调后解析code 是否返回为空
+ (NSString *)rangeOfKey:(NSString *)key fromString:(NSString *)stringValue;

+ (UIColor *)hexColor:(NSString *)hexColor;

+ (UIFont *)defaultFontWithSize:(CGFloat)aSize;

+ (UIFont *)defaultFontWithBoldSize:(CGFloat)aSize;

+ (NSString *)stringFromDate:(NSDate *)aDate format:(NSString *)aFormat;

+ (NSDate *)dateFromString:(NSString *)string format:(NSString *)aFormat;

+ (NSString *)localDate;

+ (int)daysFromDateString:(NSString *)string1 toDateString:(NSString *)string2;

+ (BOOL)validatePaymentPassword:(NSString *)password;

+ (BOOL)validateEmail:(NSString *)email;

+ (BOOL)validateUserId:(NSString *)userId;

+ (BOOL)validateMobile:(NSString *)mobileNum;

+ (BOOL)validateChinese:(NSString *)value;

+ (BOOL)validateIdCard:(NSString *)value;

+ (float)getScreenWidth;

+ (float)getScreenHeight;

+ (UIImage *)imageWithColor:(UIColor *)color withRect:(CGRect)rect;

+ (NSString *)dataFilePath:(NSString *)kFileName;

+ (NSString *)getFormatLeaveTime:(NSString *)theDate;

+ (UIImage *)scaleAndRotateImage:(UIImage *)photoimage
                           width:(CGFloat)bounds_width
                          height:(CGFloat)bounds_height
                        isCamera:(BOOL)isCamera;

+ (UIImage*)OriginImage:(UIImage*)image scaleToSize:(CGSize)size;

+ (NSString *)getDocumentDirectory;

+ (NSString *)getCacheDirectory;

+ (NSString *)getCacheImagePath;

+ (NSString *)getPassbookPath;

+ (NSString *)getBrowseHistoryPath;

+ (NSString *)getTmpDirectory;

+ (NSString *)getH5TmpDirectoryWithFileName:(NSString *)fileName;

+ (NSString *)getCacheH5Path;

+ (NSString *)getCachePath;

+ (NSString *)getTrackitCachePathByID:(NSString *)idString;

+ (BOOL)deleteCacheImage;

+ (NSString *)getMacAddress;

+ (NSString *)getMd5:(NSString *)str;

+ (NSString *)uniqueMacMd5Identifier;

+ (CGFloat)getTextHeight:(CGFloat)textWidth text:(NSString *)text fontSize:(CGFloat)fontSize isBold:(BOOL)isBold;

+ (CGFloat)getTextWidth:(CGFloat)textHeight text:(NSString *)text fontSize:(CGFloat)fontSize isBold:(BOOL)isBold;

+ (NSString *)deviceString;

+ (NSString *)stringWithUUID;

+ (NSString *)formatMobile:(NSString *)mobile;

+ (NSString *)getTrimString:(id)str;

+ (UIAlertController *) showAlert:(NSString *)title Content:(NSString *)content;

+ (BOOL)isBlank:(id)obj;

+ (BOOL)isNull:(id)obj;

/**
	查找parentView的子view类型为type的View
	@param type 类型
	@returns 为该类型的第一个View
 */
+ (UIView *) parentView:(UIView *)parentView subViewByType:(Class)type;


+ (NSString *)flattenHTML:(NSString *)html;

+ (void)clearLvSessionCookie;

+ (NSString *)getNumberStringValue:(float)number;

+ (NSString *)getIPAddress;


+ (NSString *)intToString:(NSInteger)num;  //

+ (NSString *)Version;


+ (NSDateComponents *)componentsFromDateString:(NSString*)dateStr;


//屏幕截图
+ (UIImage *)imageFromView:(UIView *)theView;

+ (UIImage *)imageFromView:(UIView *)theView atFrame:(CGRect)r;

+ (UIImage *)imageFromView:(UIView *)theView cover:(UIImage *)coverImage;

+ (int)floatToInt:(float)f;


+ (NSString *)getShortPinyin:(NSString *)chinese isFirstPinyin:(BOOL)isFirstPinyin;

+ (NSInteger)convertToInt:(NSString*)strtemp;

+ (NSString *)getDistance:(double)distance;
+ (double)getDistanceNumber:(CLLocationCoordinate2D)newCoordinate locationOld:(CLLocationCoordinate2D)oldCoordinate;

//汉子转为拼音
+ (NSString *)chineseToPinYin:(NSString*)sourceString;


//是否安装第三方地图APP
+ (BOOL)installBaiduMapApp;
+ (BOOL)installGaodeMapApp;

+ (NSString *)daySpecialStringFromdDate:(NSDate *)aDate; //返回 今天、明天、后天  若不符合 则返回空


+ (NSString *)dayStringFromDate:(NSDate *)aDate;  //返回 周一、周二、周三...


+ (NSString *)weekStringFromDate:(NSDate *)aDate;

+ (NSString *)weekDayFormDateString:(NSString *)dateString;

//从NSDate 显示 。。月。。日
+ (NSString *)monthDayFormDate:(NSDate *)date;

//从NSString 显示 。。月。。日
+ (NSString *)monthDayFormDateString:(NSString *)dateString;

//从NSDate 显示  年。。月。。日
+ (NSString *)yearDayFormDate:(NSDate *)date;

+ (NSString *)yearDayFormDateString:(NSString *)dateString;
//返回时间戳
+ (double )timeDateString:(NSString *)dateString;

//获取目标日期x天后的日期
+ (NSDate *)getFutureDateByServalDay:(NSDate *)aDate inDays:(int)days;
//获取目标日期x月后的月份
+ (NSDate *)getFutureDateByServalMonth:(NSDate *)aDate inMonths:(int)months;

+ (NSString *)convertToJSONData:(id)infoDict;

+ (NSString *)getPreferredLanguage;

@end
